<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>方法调度</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../static/css/element-ui-2.6.14.css">
    <style>
        .el-main {
            color: #333;
            padding: 0;
            background:white;
            text-align: center;
        }
        .el-main .el-tabs__header .el-tabs__nav-scroll{
            padding-left: 30px;
        }
        .el-main .el-tabs__content{
            padding: 30px;
        }
        .el-main .el-tabs__content .el-select{
            width: 100%;
        }
        .el-main .el-tabs__content .el-input-number{
            width: 100%;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-main>
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="注册配置" name="user_regist">
                    <el-form ref="userRegistFormRef" label-position="left" label-width="100px" :model="userRegistForm">
                        <el-row :gutter="60">
                            <el-col :span="8" type="flex" >
                                <el-form-item label="注册状态">
                                    <el-switch
                                        v-model="userRegistForm.status"
                                        active-value="ON"
                                        active-color="#13ce66"
                                        active-text="开启"
                                        inactive-value="OFF"
                                        inactive-color="#ff4949"
                                        inactive-text="关闭">
                                    </el-switch>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                            </el-col>
                        </el-row>
                        <el-row :gutter="60">
                            <el-col :span="8">
                                <el-form-item label="注册角色">
                                    <el-select v-model="userRegistForm.regist_role" placeholder="请选择">
                                        <el-option
                                            v-for="item in roleList"
                                            :key="item.id"
                                            :label="item.roleName"
                                            :value="item.roleCode"
                                            :disabled="item.status == 'OFF'">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="过期角色">
                                    <el-select v-model="userRegistForm.expiry_role" placeholder="请选择">
                                        <el-option
                                            v-for="item in roleList"
                                            :key="item.id"
                                            :label="item.roleName"
                                            :value="item.roleCode"
                                            :disabled="item.status == 'OFF'">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="60">
                            <el-col :span="8">
                                <el-form-item prop="def_expiry_time" label="默认充值分钟" lable-width="80px">

                                    <el-input-number
                                            :controls="true"
                                            v-model="userRegistForm.def_expiry_time"
                                            :min="10"
                                            :max="1440*3"
                                            :precision="0"
                                    ></el-input-number>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="过期提醒分钟">
                                    <el-input-number
                                            :controls="true"
                                            v-model="userRegistForm.expiry_tip_time"
                                            :min="10"
                                            :max="1440*3"
                                            :precision="0"
                                    ></el-input-number>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="60">
                            <el-col :span="8">
                                <el-form-item label="创建人">
                                    <el-input v-model="userRegistForm.create_by" disabled></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="创建时间">
                                    <el-input v-model="userRegistForm.create_time" disabled></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="60">
                            <el-col :span="8">
                                <el-form-item label="更新人">
                                    <el-input v-model="userRegistForm.update_by" disabled></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="更新时间">
                                    <el-input v-model="userRegistForm.update_time" disabled></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row :gutter="60">
                            <el-col :span="16">
                                <el-form-item>
                                    <el-button @click="initUserRegistCfg">刷新</el-button>
                                    <el-button type="primary" @click="updateUserRegistCfg" v-if="auth.userRegistUpdate">保存</el-button>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-tab-pane>
                <el-tab-pane label="共享域名" name="share_domain">共享域名</el-tab-pane>
            </el-tabs>
        </el-main>
    </el-container>
</div>

<script type="text/javascript" src="../static/js/vue.min-2.6.14.js"></script>
<!-- 引入组件库 -->
<script src="../static/js/element-ui-2.15.6.js"></script>
<script src="../static/js/axios.min.js"></script>
<script src="../static/js/app.js"></script>
<script>

    new Vue({
        el: '#app',
        data:{
            activeName: "user_regist",
            userRegistForm: {},
            roleList:[],
            auth:{
                menuCode:'sys_config',
                userRegistUpdate:false
            }

        },
        created(){
            initAuth(this.auth);
            this.initUserRegistCfg();
            this.initRoleList();
        },
        methods: {
            handleClick(tab, event) {
                console.log(tab, event);
            },
            initUserRegistCfg(){
                axios.get(domain + "/sysConfig/getUserRegistCfg").then(resp=>{
                    const res = resp.data;
                    if (res.status == 200){
                        this.userRegistForm = res.data;
                    }else {
                        notify(resp)
                    }
                });
            },
            updateUserRegistCfg(){

                axios.post(domain + "/sysConfig/updateUserRegistCfg",{
                    regist_role: this.userRegistForm.regist_role,
                    expiry_role: this.userRegistForm.expiry_role,
                    status: this.userRegistForm.status,
                    def_expiry_time: this.userRegistForm.def_expiry_time,
                    expiry_tip_time:this.userRegistForm.expiry_tip_time
                }).then(resp=>{
                    notifyAndReload(this, resp, "initUserRegistCfg")
                });
            },
            initRoleList(){
                axios.get(domain + "/sysRole/getAllSysRole").then(resp=>{
                    const res = resp.data;
                    if (res.status == 200){
                        this.roleList = res.data;
                    }else {
                        notify(resp)
                    }
                });
            }
        }
    })

</script>
</body>
</html>
